Repository navigation
[minor] Transition internal GHE repo sync to native Git ref mirroring - #658
devanshraghuvanshi wants to merge 19 commits into
Conversation
…est for workflow run
…o MASCORE-18527
| fi | ||
| echo "Pushing mirror refs to https://github.ibm.com/${TARGET_REPO}..." | ||
| # Explicitly push heads and tags; avoid pushing internal GitHub pull-request refs | ||
| git push --prune --force "https://x-access-token:${GHE_TOKEN}@github.ibm.com/${TARGET_REPO}.git" "refs/heads/*:refs/heads/*" "refs/tags/*:refs/tags/*" |
There was a problem hiding this comment.
We should clone and push with --mirror option for mirroring
There was a problem hiding this comment.
Hi @mnivedithaa
I tested using git clone --mirror and git push --mirror, but GitHub Enterprise rejects the push with:
! [remote rejected] refs/pull/1/head -> refs/pull/1/head (deny updating a hidden ref)
! [remote rejected] refs/pull/658/merge -> refs/pull/658/merge (deny updating a hidden ref)
error: failed to push some refs to 'https://github.ibm.com/automation-paas-cd-pipeline/mas-gitops.git'
Reason:
--mirror attempts to push everything in the repository, including GitHub's internal Pull Request data (refs/pull/). However, GitHub Enterprise treats refs/pull/ as protected read-only system data and blocks any external push trying to update it.
Why our approach works:
Using git clone --bare + git push --prune --force ... "refs/heads/:refs/heads/" "refs/tags/:refs/tags/" gives the exact 1:1 mirror of all actual branches, tags, commit history, and deletions (--prune), while avoiding GitHub's internal Pull Request references (refs/pull/*).
…o MASCORE-18527
…ub internal refs/pull/* rejection
222671f
Native Git Ref Mirroring Implemented:
.github/workflows/update-internal-repo.yaml:
Obsolete Scripts Removed:
Documentation Updated: